<?php
/**
 * Zhub - A PHP Framework For API Developer
 *
 * This file is part of the Zhub package.
 *
 * (c) YiLong Fan <fantiq@163.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @author fanyilong <fantiq@163.com>
 * @copyright 2017 fanyilong. All rights reserved.
 * @package Zhub
 * @date 18-3-14
 */

namespace Zhub\Application\Http;

use Zhub\HttpMessage\Request;
use Zhub\Route\RouteStruct;

class RoutingContext
{
    private $request = null;

    private $route = null;

    public function __construct(Request $request, RouteStruct $route)
    {
        $this->request = $request;

        $this->route = $route;
    }

    public function request():Request
    {
        return $this->request;
    }

    public function route():RouteStruct
    {
        return $this->route;
    }

    public function pathVariable()
    {
        return $this->route->getParameters();
    }

    public function query()
    {
        return $this->request()->getUrl()->getPath();
    }

    public function input()
    {
        return $this->request()->getBody();
    }
}